home *** CD-ROM | disk | FTP | other *** search
/ Ray Dream Studio 5 / Ray Dream.iso / pc / DreamSDK / Windows / INCLUDES / I3DEXMDR.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-11  |  14.7 KB  |  257 lines

  1. /* $Id: I3DExMdr.h 1.16 1997/06/30 18:51:11 YannPC Exp $ */
  2. /*****************************************************************************\
  3. *                                                                             *
  4. * I3DExMdr.h                                                                          *
  5. *   I3DExModeler definition                                                   *
  6. *   I3DExModelerOperation definition                                          *
  7. *                                                                             *
  8. *   External modelers interface                                               *
  9. *   External commands for external modelers interface                         *
  10. *                                                                             *
  11. *           Copyright (c) 1996, Fractal Design Corp. All rights reserved.     *
  12. *                                                                             *
  13. \*****************************************************************************/
  14.  
  15. #ifndef __I3DEXMDR__
  16. #define __I3DEXMDR__
  17.  
  18. #ifndef __I3DEXMDU__
  19. #include "I3DExMdu.h"
  20. #endif
  21.  
  22. //****** Globally Unique Ids **************************************************
  23. DEFINE_GUID(IID_I3DExModeler, 0x4656c080, 0xba0f, 0x11cf, 0x99, 0x09, 0x00, 0x40, 0x05, 0x22, 0xbf, 0xcc);
  24. DEFINE_GUID(IID_I3DExModelerOperation, 0x47fa5e60, 0xba0f, 0x11cf, 0x99, 0x09, 0x00, 0x40, 0x05, 0x22, 0xbf, 0xcc);
  25.  
  26. struct I3DExModelerOperation;
  27.  
  28. /*****************************************************************************\
  29. *    Important note about the 'Modu' resource:
  30. *
  31. *       For External Modelers, the value of the 'Workspace class signature' field
  32. *         MUST be 'PeRs'.
  33. *
  34. \*****************************************************************************/
  35.  
  36.  
  37. /*****************************************************************************\
  38. *    Private data of the Modeler (stored in the Cmpp resource of same ID).    *
  39. *                                                                             *
  40. *    Theory:                                                                  *
  41. *                                                                             *
  42. *    The Cmpp resource contains data for the Shell, so the Shell can learn    *
  43. *    which type of Primitive(s) the Modeler can edit directly or indirectly.  *
  44. *                                                                             *
  45. \*****************************************************************************/
  46. // Used in SExModelerData:
  47. typedef struct {
  48.     long    fPrimitiveID;                    // Primitive Class ID that the modeler can edit
  49.     long    fNative;                            // If TRUE, then the modeler knows how to modify the primitive's data in place.
  50.                                                             // In this case, the pointer received in Edit() will be a pointer on the primtive.
  51.                                                             // If FALSE, then an empty primitive of the first 'native' type will be created
  52.                                                             // by the Shell, and then the pointer on the original primitive will be passed
  53.                                                             // to the modeler thru the Import() call, just after Edit() has been called.
  54.                                                             // In that case, the modeler is supposed to get whatever data it can get,
  55.                                                             // and convert it into data for the empty primitive passed to Edit().
  56.     } SExModelerPrimitiveData;
  57.  
  58. // Structure of the Cmpp resource:
  59. typedef struct    {
  60.     long    fCanEditPatches;            // TRUE if modeler can edit any patch based object
  61.     long    fCanEditFacets;                // TRUE if modeler can edit any facet based object
  62.     long    fPrimitiveIDNb;                // Number of primitive Class IDs in fPrimitiveIDList
  63.     SExModelerPrimitiveData    fPrimitiveList[1];    // List of primitive Class IDs
  64.     } SExModelerData;
  65.  
  66. /*****************************************************************************\
  67. *    Notes on the Planes Tool (for I3DExModeler::SetPlanesTool())             *
  68. *                                                                             *
  69. *    Theory:                                                                  *
  70. *                                                                             *
  71. *         After I3DExModeler::Edit() is called, I3DExModeler::SetPlanesTool() is   *
  72. *         called to pass the Planes Tool pointer to the modeler.                   *
  73. *    When the user clicks inside the planes tool, I3DExModeler::OnMenuAction()*
  74. *         will be called with a specific action number (see constants below).      *
  75. *         You can also set and get the current status of the Planes Tool by using  *
  76. *    gViewManager->SetValues() and gViewManager->GetValues() using the        *
  77. *    constants below.                                                         *
  78. *                                                                             *
  79. \*****************************************************************************/
  80.  
  81. //-- Action numbers:
  82. #define kPTChangePlanes 9460
  83. #define kPTChangeActivePlane 9461
  84.  
  85. //-- GetValues/SetValues: , and
  86. // The 4 lower bits give the number of the Drawing plane
  87. #define kPTBotDrw            0x00000000L
  88. #define kPTRightDrw        0x00000001L
  89. #define kPTLeftDrw        0x00000002L
  90. // The 4 next bits give the status of each sub part.
  91. #define kPTBot                0x00000010L
  92. #define kPTRight            0x00000020L
  93. #define kPTLeft                0x00000040L
  94. #define kPTCube                0x00000080L
  95.  
  96.  
  97.  
  98. /*****************************************************************************\
  99. *  I3DExModeler                                                               *
  100. *                                                                             *
  101. *   External Modelers interface                                               *
  102. *                                                                             *
  103. *                                                                             *
  104. \*****************************************************************************/
  105.  
  106. #undef INTERFACE
  107. #define INTERFACE I3DExModeler
  108.  
  109. DECLARE_INTERFACE_(I3DExModeler, I3DExModule) {
  110.     // IUnknown methods
  111.   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  112.   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
  113.   STDMETHOD_(ULONG, Release) (THIS) PURE;
  114.   
  115.     // I3DExtension methods
  116.     STDMETHOD(ShellUtilitiesInit) (THIS_ IShUtilities* shellUtilities) PURE;
  117.     STDMETHOD_(I3DExtension*, Clone) (THIS) PURE;
  118.  
  119.   // I3DExDataExchanger methods
  120.     STDMETHOD_(ExtensionDataMap*, GetExtensionDataMap) (THIS) PURE;    // Return NULL if GetResID is to be used
  121.     STDMETHOD_(void*, GetExtensionDataBuffer) (THIS) PURE;
  122.   STDMETHOD(ExtensionDataChanged) (THIS) PURE;
  123.   STDMETHOD(HandleEvent) (THIS_ ULONG sourceID) PURE;
  124.     STDMETHOD_(short, GetResID) (THIS) PURE;
  125.  
  126.     // I3DExModule methods
  127.     STDMETHOD(SetPrefs) (THIS_ void* prefs) PURE;        // 'prefs' is a pointer given by the Shell on the Module's Preferences data block
  128.     STDMETHOD(Edit) (THIS_ IUnknown* element) PURE;
  129.     STDMETHOD(Import) (THIS_ IUnknown* element, void* parameters) PURE;
  130.     STDMETHOD(PrepareMenus) (THIS) PURE;
  131.     STDMETHOD_(BOOLEAN, OnMenuAction) (THIS_ IShContext* context, long actionNumber) PURE;
  132.     STDMETHOD_(BOOLEAN, OnKeyEvent) (THIS_ IShContext* context, PLATFORMEVENT* event) PURE;
  133.     STDMETHOD(OnToolAction) (THIS_ IShContext* context, short oldTool, short newTool) PURE;
  134.     STDMETHOD(Activate) (THIS_  IShContext* context, BOOLEAN entering) PURE;
  135.     STDMETHOD(Update) (THIS_  IShContext* context, I3DShScene* scene, long change) PURE;
  136.     STDMETHOD(Do) (THIS_ IShContext* context, ULONG message, void* data, void** result) PURE;
  137.     STDMETHOD_(BOOLEAN, LaunchToolDragAndDrop) (THIS_ short tool) PURE;
  138.     STDMETHOD_(BOOLEAN, GetZoomEffect) (THIS_ void* prevElem, void* nextElem, Boolean* zoomIn) PURE;
  139.     STDMETHOD_(BOOLEAN, PropertiesChanged) (THIS) PURE;    // Return TRUE if GetPropertiesInfo() should be called to update the the Properties Palette
  140.     STDMETHOD_(BOOLEAN, GetPropertiesInfo) (THIS_ short& viewAndPMapID, void*& dataBuffer, void*& privData, 
  141.                                                                         BOOLEAN& forceShowProperties,
  142.                                                                         OnMessagePropsCallBack& onMessageCallBack,         // The External Module should return its View callback here
  143.                                                                         DrawNowPropsCallBack drawNowPropsCallBack, void* module) PURE; // The Shell is giving this callback so that the External Modeler can redraw the Properties view immediately
  144.     STDMETHOD(DoApplyProperties) (THIS_ IShContext* context, IShView* topView, void* privData) PURE;
  145.     STDMETHOD(DoRestoreProperties) (THIS_ IShContext* context, IShView* topView, void* privData) PURE;
  146.  
  147.     // I3DExModeler methods
  148.     STDMETHOD(SetPlanesTool) (THIS_ IShControl* planesTool) PURE; // Called just after Edit(). The modeler can store this pointer in order to play with the Planes tool. See notes above
  149.     STDMETHOD_(BOOLEAN, JumpOut) (THIS_ BOOLEAN regJumpOut) PURE;    // Called when jumping out. 'regJumpOut' is TRUE if regular jump-out, FALSE if exiting thru the 'Restore' button. Should return TRUE if the hot point should be centered on the object's bbox
  150.     // OperationDoneit(), OperationUndoneit(), OperationRedoneit(), OperationReleased() are used
  151.     // so the Modeler can be made aware that a Modeler Operation has been undone, undone, redone
  152.     // or disposed of. Use it to update any internal data (cache invalidation, etc.)
  153.     // 'changedData' is what is returned by I3DExModelerOperation::Doit(), Undoit(), and Redoit()
  154.     STDMETHOD(OperationDoneit) (THIS_ I3DExModelerOperation* modelerOperation, BOOLEAN changedData) PURE;
  155.     STDMETHOD(OperationUndoneit) (THIS_ I3DExModelerOperation* modelerOperation, BOOLEAN changedData) PURE;
  156.     STDMETHOD(OperationRedoneit) (THIS_ I3DExModelerOperation* modelerOperation, BOOLEAN changedData) PURE;
  157.     STDMETHOD(OperationReleased) (THIS_ I3DExModelerOperation* modelerOperation) PURE;
  158.   };
  159.  
  160.  
  161. /*****************************************************************************\
  162. *  I3DExModelerOperation                                                      *
  163. *                                                                             *
  164. *   External commands for external modelers interface                         *
  165. *
  166. *   Implements a convenient way to add commands to an external modeler by
  167. *   adding menu items, toolbar buttons or Properties Palette actions.
  168. *
  169. *   The ClassID of the Modeler to which the operation belongs is stored in the
  170. *   Cmpp resource (see SExModelerOperationData below).
  171. *
  172. *   Toolbar buttons:
  173. *    If the operation is a toolbar button, then a icl8 icon resource of the
  174. *    same ID should be provided. The "down" state of the button should also
  175. *    be provided as a icl8 icon of ID+50.
  176. *   Menu items:
  177. *    The "SubFamily name" in the COMP resource is used to group operations in
  178. *    a sub-menu of that name. Put an empty string to just have the operation added
  179. *    directly in the menu.
  180. *   Palette actions:
  181. *    You need to have a sub view in your palette of type TView with a 
  182. *         "TModelerOperationList" Class Name and the (unique) 'XOpL' ID. 
  183. *         This view automatically takes care of the 
  184. *    list of Palette Modeler Operations for this modeler and handles
  185. *         everything for you. This view should have a sub view of type "TPopupView" with
  186. *    a 'MENU' ID (this is the pop-up menu containing the list of Operations),
  187. *    and another sub view of type "TView" with a 'COVW' ID (this is where the
  188. *    Operation UI will show up). If you want to have the name of the operation
  189. *    shown automatically in a static text, set up a sub view of type TStaticText
  190. *    with an 'NAME' ID (this is optional).
  191. *    As usual, the top view of your Modeler Operation should be a TView of the
  192. *    TComponentView class, but it MUST have an 'EDIT' ID.
  193. *
  194. *    Note: since the Properties Palette can be in 'auto' mode, it is important
  195. *    to have 'good' default values in your UI, because your operation will be
  196. *    immediately launched after being chosen in the pop-up menu
  197. *
  198. *                                                                             *
  199. *                                                                             *
  200. \*****************************************************************************/
  201.  
  202. /*****************************************************************************\
  203. *    Private data of the operation (stored in the Cmpp resource of same ID).    *
  204. \*****************************************************************************/
  205.  
  206. // Type of Modeler Operation:
  207. #define kShToolModelerOp            0        /* Toolbar button */
  208. #define kShMenuModelerOp            1        /* Menu item */
  209. #define kShPaletteModelerOp        2        /* Palette action */
  210.  
  211. typedef struct    {
  212.     long            fModelerID;            // Class ID of the modeler to which the operation belongs
  213.     long            fType;                    // kShToolModelerOp, kShMenuModelerOp, or kShPaletteModelerOp
  214.     long            fInsertAfter;        // Rank after which the menu item or the tool should be inserted. -1 for the end.
  215.     //-- If Menu type:
  216.     long            fSeparator;            // TRUE if a 'separator' line should be inserted before the menu item
  217.     long            fTargetMenu;        // Menu ID to which the operation should be added
  218.     //-- If Toolbar button type:
  219.     short            fIconID;                // ID of the icl8 resource. Selection icon is an icl8 resource of fIconID+50
  220.     short            fToolKey;                // Key stroke equivalent to the button
  221.     long            fActionNumber;    // Unique identifier of the button
  222.     //-- If Palette action type:
  223.     /* no parameters */
  224.     } SExModelerOperationData;
  225.  
  226. #undef INTERFACE
  227. #define INTERFACE I3DExModelerOperation
  228.  
  229. DECLARE_INTERFACE_(I3DExModelerOperation, I3DExDataExchanger) {
  230.     // IUnknown methods
  231.   STDMETHOD(QueryInterface) (THIS_ REFIID riid, LPVOID FAR* ppvObj) PURE;
  232.   STDMETHOD_(ULONG, AddRef) (THIS) PURE;
  233.   STDMETHOD_(ULONG, Release) (THIS) PURE;
  234.   
  235.     // I3DExtension methods
  236.     STDMETHOD(ShellUtilitiesInit) (THIS_ IShUtilities* shellUtilities) PURE;
  237.     STDMETHOD_(I3DExtension*, Clone) (THIS) PURE;
  238.  
  239.   // I3DExDataExchanger methods
  240.     STDMETHOD_(ExtensionDataMap*, GetExtensionDataMap) (THIS) PURE;    // Return NULL if GetResID is to be used
  241.     STDMETHOD_(void*, GetExtensionDataBuffer) (THIS) PURE;
  242.   STDMETHOD(ExtensionDataChanged) (THIS) PURE;
  243.   STDMETHOD(HandleEvent) (THIS_ ULONG sourceID) PURE;
  244.     STDMETHOD_(short, GetResID) (THIS) PURE;
  245.  
  246.   // I3DExModelerOperation methods
  247.   STDMETHOD_(BOOLEAN, Enable) (THIS_ IUnknown* data) PURE;                    // Enable menu or tool ?
  248.   STDMETHOD(SetModeler) (THIS_ IUnknown* modeler) PURE;                            // This gives a chance to do private chat with the modeler launching the operation
  249.   STDMETHOD(Prepare) (THIS_ IUnknown* data, BOOLEAN* canUndo) PURE; // Called just before opening the dialog (if any)
  250.     STDMETHOD_(BOOLEAN, DoIt) (THIS_ IUnknown* data) PURE;                        // Perform the operation. Return TRUE if data was changed.
  251.     STDMETHOD_(BOOLEAN, UndoIt) (THIS_ IUnknown* data) PURE;                    // Undo the operation. Return TRUE if data was changed.
  252.     STDMETHOD_(BOOLEAN, RedoIt) (THIS_ IUnknown* data) PURE;                    // Do it again. Return TRUE if data was changed.
  253.     STDMETHOD_(BOOLEAN, ForceRedraw) (THIS_ IUnknown* data) PURE;            // Should return TRUE if the view (if any) should be redrawn
  254.     };
  255.  
  256. #endif
  257.